package com.yumeko.controller;

import com.yumeko.entity.TPayment;
import com.yumeko.utils.ResponseData;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @program: SpringCloudAlibaba
 * @description:
 * @author: Zheng Hao
 * @create: 2020-03-17 19:58
 */
@RestController
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, TPayment> hashMap = new HashMap<>();

    static {
        hashMap.put(1L, new TPayment(1L, "28a8c1e3bc2742d8848569891fb42181"));
        hashMap.put(2L, new TPayment(2L, "28a4c1e3bc2742d8848569891fb42181"));
        hashMap.put(3L, new TPayment(3L, "28a5c1e3bc2742d8848569891fb42181"));
    }

    @GetMapping(value = "/paymentSQL/{id}")
    public ResponseData<TPayment> paymentSQL(@PathVariable("id") Long id){
        TPayment payment = hashMap.get(id);
        ResponseData<TPayment> result = new ResponseData<>(200, "from mysql,serverPort: " + serverPort, payment);
        return result;
    }
}
